<template>
  <div class="detail-item">
    <smart-bar>
      <div
        class="titles"
        slot="center">
        <div
          class="item-title"
          :class="{ active: currentIndex === index }"
          v-for="(item, index) in titles"
          :key="index"
          @click="changeClick(index)">
          {{item}}
        </div>
        </div>
      <div slot="left">
        <img src="../back-top.png" alt=""
          @click="backClick">
      </div>  
    </smart-bar>
  </div>
</template>

<script>
import SmartBar from './SmartBar.vue'
export default {
  name: 'Detail',
  components: {
    SmartBar
  },
  data() {
    return {
      titles:['商品', '参数', '评论', '推荐'],
      currentIndex: 0 
    }
  },
  methods: {
    changeClick (index) {
      this.currentIndex = index
    },
    backClick () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped>
.titles {
  display: flex;
}
.item-title {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
</style>>
